This application claims priority to S.N. 98402464.6, filed in Europe on Oct. 6, 1998 (TI-27691EU) and S.N. 98402455.4, filed in Europe on Oct. 6, 1998 (TI-28433EU).
The present invention relates to circular buffers, the management of circular buffers and processing engines providing circular buffer management.
Circular addressing of memory can be useful in processor design for implementing many different types of processes, such as processes involving, for example, Viterbi, back-tracking, de-interleaving and vocoder computations.
It has been proposed to implement circular buffers in random access memory, where a circular buffer is defined with a defined buffer size (BK) aligned with predetermined memory boundaries. For example, it has been proposed to align circular buffers of a size R at memory boundary represented by the N lowest significant bits of the address being 0. The circular buffer then starts at an index of 0 with respect to the boundary where N is the smallest value such that 2N greater than R. For example the circular buffers could be aligned on 64 word boundaries. A circular buffer manager controls access to the circular buffer(s) through the use of pointers to the physical memory space. The requirement to align the circular buffers on memory boundaries can mean that inefficient use of space is achieved. For example, if a 38 word buffer has to be aligned on 64 word boundaries and a plurality of circular buffers are held in memory, the memory rapidly becomes fragmented, 26 words being unused between adjacent circular buffers. Also, in order to provide efficient control of circular buffers under certain programming languages, it is not desirable to have any alignment constraint.
An aim of the invention, therefore, is to provide for circular buffer management without the disadvantages of the prior approach.
Particular and preferred aspects of the invention are set out in the accompanying independent and dependent claims. Combinations of features from the dependent claims may be combined with features of the independent claims as appropriate and not merely as explicitly set out in the claims.
In accordance with a first aspect of the invention, there is provided data processing apparatus supporting circular buffers. The apparatus comprises address storage for holding a virtual buffer index, offset storage for holding an offset address and buffer size storage for holding a buffer size. Circular buffer management logic is configured to be operable to apply a modifier to a virtual buffer index held in the address storage to derive a modified virtual buffer index and to apply a buffer offset held in the offset storage to the modified virtual buffer index to derive a physical address for addressing a circular buffer.
By employing virtual addressing to a buffer index for a circular buffer management, it is possible to make efficient use of memory resources by allowing one of more circular buffers to be located contiguously with each other or other data in memory, avoiding fragmentation of the memory. The buffer index forms a pointer for the circular buffer. The modifier can be defined by a user, or could be generated automatically in response to parameters such as the buffer size.
The use of virtual addressing also allows compatibility with existing software designed for apparatus which aligns the circular buffers with memory boundaries. The virtual address modification is transparent to the pre-existing software.
The use of virtual addressing can also facilitate the implementation of circular buffers using programming languages, for example the xe2x80x9cCxe2x80x9d programming language, which do not support memory alignment constraints.
The buffer offset can define a buffer start address, which can be held in an offset register. This can then be added to the modified virtual buffer index to derive a physical circular buffer address. The original and modified virtual buffer addresses can be held in an address register.
The address storage can be formed by a predetermined number of lower significant bits of an address register. The modified virtual buffer index can also be held in the predetermined number of lower significant bits of the address register. Higher order bits in the address register (typically the remainder of the address register) can define a buffer start address, whereby the combination of the higher and lower order bits in the address register defines a physical address.
The buffer offset, which can be held in an offset register, can be added to the physical address in the address register to define a physical address for addressing the circular buffer.
The apparatus can include random access memory for holding the circular buffer.
As an alternative to implementing a circular buffer in memory, an embodiment of the invention can provide manipulation of a bit array, which may be held in memory or in one or more processor registers.
A pointer configuration register can be provided for selectively setting a circular buffer mode for an address register. An exception mode qualifier can be provided for dynamically overriding the setting of a circular buffer mode. The qualifier can also be used dynamically to define whether the address storage is operable in a circular or a linear addressing mode.
In a circular buffer address computation mechanism, carry signals from first and second addition/subtraction computations are used in the computation of a sign value to determine the selection of the result of one of the addition/subtraction operations for the computation of a circular buffer address. The use of the carry signals in this manner can avoid the need for an initial masking step, with a consequent improvement in the speed path of the apparatus.
The apparatus can be in the form of digital signal processing apparatus, providing a digital signal processor (DSP), and can be implemented in one or more integrated circuits. The random access memory can be internal or external to the integrated circuit(s).
An embodiment of the invention finds application to telecommunications apparatus, where circular buffer functions find particular utility for processes involving, for example, Viterbi, back-tracking, de-interleaving and vocoder computations.
In accordance with another aspect of the invention, there is provided a method for managing circular buffer addressing in a data processing apparatus. The method comprises
deriving a virtual buffer index;
modifying the virtual buffer index to derive a modified virtual buffer index;
adding a buffer offset to the modified virtual buffer index derive a circular buffer address.